package com.huatech.core.support.json;

import java.lang.reflect.Type;
import java.nio.charset.Charset;

import com.alibaba.fastjson.JSONObject;

public class JsonUtil {
	
	public static final Charset CHARSET = Charset.forName("UTF-8");
	
	 public static <T> byte[] serialize(T obj) {
		 String result = JSONObject.toJSONString(obj);
		 return result.getBytes(CHARSET);
	 }
	 
	 public static <T> T deserialize(byte[] data, Type clazz) {
		 String result = new String(data, CHARSET);
		 return JSONObject.parseObject(result, clazz);
	 }
	 

}
